package it.fuesi.synoutils.model.base;

import it.fuesi.synoutils.constants.ApiErrorCode;

/**
 * Created by pascotto on 16/10/14.
 */
public class ErrorObject {

    private int code;
    private String message;
    private ApiErrorCode errorCode;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
        errorCode = ApiErrorCode.get(code);

    }

    public void setMessage(String message){
        this.message = message;
    }

    public String getMessage(){
        if(message != null) return message;

        if(errorCode == null && code > 0)
            errorCode = ApiErrorCode.get(code);
        return errorCode.getErrorMessage();
    }
}
